﻿Imports System
Imports System.ComponentModel.Design

Namespace System.Workflow.ComponentModel.Design
    Public Class ActivityDesignerVerb
        Inherits DesignerVerb
        ' Methods
        Public Sub New(ByVal activityDesigner As ActivityDesigner, ByVal verbGroup As DesignerVerbGroup, ByVal [text] As String, ByVal invokeHandler As EventHandler)
            MyBase.New([text], New EventHandler(AddressOf ActivityDesignerVerb.OnExecuteDesignerVerb), New CommandID(WorkflowMenuCommands.MenuGuid, 0))
            If (([text] Is Nothing) OrElse ([text].Length = 0)) Then
                Throw New ArgumentNullException("text")
            End If
            If (invokeHandler Is Nothing) Then
                Throw New ArgumentNullException("invokeHandler")
            End If
            Me.verbGroup = verbGroup
            Me.invokeHandler = invokeHandler
            Me.activityDesigner = activityDesigner
        End Sub

        Public Sub New(ByVal activityDesigner As ActivityDesigner, ByVal verbGroup As DesignerVerbGroup, ByVal [text] As String, ByVal invokeHandler As EventHandler, ByVal statusHandler As EventHandler)
            Me.New(activityDesigner, verbGroup, [text], invokeHandler)
            Me.statusHandler = statusHandler
        End Sub

        Private Shared Sub OnExecuteDesignerVerb(ByVal sender As Object, ByVal e As EventArgs)
            Dim verb As ActivityDesignerVerb = [TryCast](sender,ActivityDesignerVerb)
            If (Not verb Is Nothing) Then
                If (Not verb.invokeHandler Is Nothing) Then
                    verb.invokeHandler.Invoke(sender, e)
                End If
                Dim oleStatus As Integer = verb.OleStatus
                If (Not verb.activityDesigner Is Nothing) Then
                    Dim verb2 As DesignerVerb
                    For Each verb2 In DirectCast(verb.activityDesigner, IDesigner).Verbs
                        If TypeOf verb2 Is ActivityDesignerVerb Then
                            Dim num2 As Integer = verb2.OleStatus
                        End If
                    Next
                End If
            End If
        End Sub


        ' Properties
        Friend ReadOnly Property ActivityDesigner As ActivityDesigner
            Get
                Return Me.activityDesigner
            End Get
        End Property

        Public Overrides ReadOnly Property CommandID As CommandID
            Get
                Return New CommandID(WorkflowMenuCommands.MenuGuid, Me.id)
            End Get
        End Property

        Public ReadOnly Property Group As DesignerVerbGroup
            Get
                Return Me.verbGroup
            End Get
        End Property

        Friend Property Id As Integer
            Get
                Return Me.id
            End Get
            Set(ByVal value As Integer)
                Me.id = value
            End Set
        End Property

        Public Overrides ReadOnly Property OleStatus As Integer
            Get
                If (Not Me.statusHandler Is Nothing) Then
                    Try 
                        Me.statusHandler.Invoke(Me, EventArgs.Empty)
                    Catch obj1 As Object
                    End Try
                End If
                Return MyBase.OleStatus
            End Get
        End Property


        ' Fields
        Private activityDesigner As ActivityDesigner
        Private id As Integer
        Private invokeHandler As EventHandler
        Private statusHandler As EventHandler
        Private verbGroup As DesignerVerbGroup
    End Class
End Namespace

